package data.model;

import java.util.TreeSet;

/**
 * Data structure for a task; has a name, a set of dependencies and a description
 * 
 * @author Will Home
 *
 */

public class Task implements Comparable<Task> {
	
	/** task name	 */
	private String taskName;
	
	/** task description	 */
	private String taskDesc;
	
	/** reference to actID of action belonging to this task */
	private int actRef;

	/** unique ID */
	private final int taskID;
	
	/** ID generator */
	private static int idGen = 1;
	
	/**
	 * construct new task
	 * 
	 * @param name - task name
	 */
	public Task(String name)
	{
		taskName = name;
		taskID = idGen;
		idGen++;
	}
	
	//MUTATORS
	/**
	 * assign new task name
	 * 
	 * @param name
	 */
	public void setTaskName(String name)
	{
		taskName = name;
	}

	/**
	 * assign an action to this task
	 * 
	 * @param actID
	 */
	public void setAction(int actID)
	{
		actRef = actID;
	}

	/**
	 * Add task description
	 * 
	 * @param desc
	 */
	public void setTaskDesc(String desc)
	{
		taskDesc = desc;
	}
	
	//ACCESSORS
	
	/**
	 *  
	 * @return task name
	 */
	public String getTaskName()
	{
		return taskName;
	}
	
	public String getConcName()
	{
		return taskName.replace(" ", "");
	}
	
	/**
	 *  
	 * @return action ID
	 */
	public int getAction()
	{
		return actRef;
	}
	
	/**
	 * 
	 * @return task description
	 */
	public String getTaskDesc()
	{
		return taskDesc;
	}
	
	/**
	 *  
	 * @return task ID
	 */
	public int getTaskID()
	{
		return taskID;
	}
	

	/**
	 * compares tasks by task name
	 * 
	 * @param other
	 * @return 0 if name is identical, -1 if lower, 1 if higher
	 */
	public int compareTo(Task other)
	{
		return taskName.compareTo(other.getTaskName());
	}
	
}
